package org.jg.arkanoid.gameobjects.objectpanel;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;

import javax.swing.JPanel;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.jg.arkanoid.gameobjects.Ball;
import org.jg.arkanoid.util.Vector;

public class BallPanel extends JPanel
{
	@SuppressWarnings("unused")
	private static Logger LOG = LogManager.getLogger("BallPanel.class");
	
	private static final long serialVersionUID = 1L;
	
	private Ball ball;
	
	public BallPanel(Ball ball){
		this.ball = ball;
	}
	
	public void paintComponent(Graphics g){
		super.paintComponent(g);
		Graphics2D g2 = (Graphics2D) g;

		setOpaque(false);
		
		Vector position = ball.getPosition();
		int width = ball.getWidth();
		int height = ball.getHeight();
		
		setBounds((int)position.getX(), (int)position.getY(), width, height);
		
		Ellipse2D circle = new Ellipse2D.Double(0, 0, width, height);
		g2.setPaint(ball.getColor());
		g2.fill(circle);
	}

}
